# 分析数据：使用Matplotlib创建散点图
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties 
import kNN
from numpy import *
import operator

font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=10)
datingDataMat,datingLabels = kNN.file2matrix('datingTestSet2.txt')
fig = plt.figure()
ax=fig.add_subplot(311)
ax.scatter(datingDataMat[:,1],datingDataMat[:,2],15.0*array(datingLabels),15.0*array(datingLabels))
#ax.axis([-2,25,-0.2,2.0])
plt.xlabel('玩视频游戏所消耗时间百分比', fontproperties=font_set)
plt.ylabel('每周消费的冰淇淋公升数', fontproperties=font_set)
ax=fig.add_subplot(312)
ax.scatter(datingDataMat[:,0],datingDataMat[:,1],15.0*array(datingLabels),15.0*array(datingLabels))
plt.xlabel('每年获取的飞行常客里程数', fontproperties=font_set)
plt.ylabel('玩视频游戏所消耗时间百分比', fontproperties=font_set)
ax=fig.add_subplot(313)
ax.scatter(datingDataMat[:,0],datingDataMat[:,2],15.0*array(datingLabels),15.0*array(datingLabels))
plt.xlabel('每年获取的飞行常客里程数', fontproperties=font_set)
plt.ylabel('每周消费的冰淇淋公升数', fontproperties=font_set)
plt.show()